import request from '../utils/request/sphrequest'
interface ParmasData {
	phone: string
	password: string
	code?: string
}

interface loginData {
	name: string
	nickName: string
	token: string
	userId: number
}
interface UserinfoData {
	birthday: null
	headImg: string
	loginName: string
	name: string
	nickName: string
	phoneNum: string
	id: number
}

/**
 * 登录
 * @param parmas {phone,password}
 * @returns promise
 */
export const ReqLogin = (parmas: ParmasData) => {
	return request.post<any, loginData>(`/api/user/passport/login`, parmas)
}

/**
 * 注册
 * @param parmas
 * @returns
 */
export const ReqRegister = (registerparmas: ParmasData) => {
	return request.post<any, null>(`/api/user/passport/register`, registerparmas)
}
/**
 * 获取手机验证码
 * @param phone
 * @returns
 */
export const ReqGetcode = (phone: string) => {
	return request.get<any, any>(`/api/user/passport/sendCode/${phone}`)
}
/**
 * 获取用户信息
 * @returns
 */
export const reqGetUserinfo = () => {
	return request.get<any, UserinfoData>(`/api/user/passport/auth/getUserInfo`)
}

/**
 * 退出登录
 * @returns
 */
export const ReqLogout = () => {
	return request.get(`/api/user/passport/logout`)
}
